package org.interfaceadaptation.parameter.expression.impl;

import java.util.HashMap;
import java.util.Map;

import org.interfaceadaptation.parameter.expression.Context;


public class ContextImpl implements Context {
	
	 private Object root;
	 private Map<AbstractExpression,AbstractExpressionContext> localContexts = new HashMap<AbstractExpression,AbstractExpressionContext>();
	
	 protected AbstractExpressionContext getExpressionContext(AbstractExpression expression) {
	     AbstractExpressionContext expressionContext = localContexts.get(expression);
		 if (expressionContext == null) {
			 expressionContext = expression.createExpressionContext(this);
			 localContexts.put(expression, expressionContext);
		 }
		 return expressionContext;
	 }

	@Override
	public void setRoot(Object root) {
		this.root = root;
	}
	
	@Override
	public Object getRoot() {
		return root;
	}


}
  